package net.cl.mvc.pages;

import java.io.ByteArrayOutputStream;
import java.io.PrintStream;
import java.io.PrintWriter;

import net.cl.mvc.Globals;
import net.cl.mvc.wrappers.ActionContext;
import net.cl.mvc.wrappers.RequestContext;
import net.cl.mvc.wrappers.ResponseContext;

public class GlobalError {

	public String execute() throws Exception {
		RequestContext request = ActionContext.getContext().getRequestContext();
		ResponseContext response = ActionContext.getContext().getResponseContext();
		PrintWriter out = response.getResponse().getWriter();
		Exception e = (Exception) request.getAttribute(Globals.EXCEPTION_KEY);
		ByteArrayOutputStream ostr = new ByteArrayOutputStream();
		e.printStackTrace(new PrintStream(ostr));
		out.println(ostr.toString());
		out.close();
		return null;
	}

}
